from time import sleep
from concurrent.futures.process import ProcessPoolExecutor
# from concurrent.futures.thread import ThreadPoolExecutor

from utils.handler import Handler
from utils.log import Log


class MyClass(Log):
    def __init__(self):
        self.i = 0

    @Handler()
    def f(self):
        self.i += 1
        self.info(self.i)

    @Handler()
    def g(self):
        sleep(2)
        self.info(f"g {self.i}")


def main():
    my_class = MyClass()
    pool = ProcessPoolExecutor(max_workers=5)
    pool.submit(my_class.f)
    pool.submit(my_class.f)
    pool.submit(my_class.f)
    pool.submit(my_class.f)
    pool.submit(my_class.g)
    pool.shutdown()


if __name__ == '__main__':
    main()
